﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AutoTaskSchedule.Core.Business;
using AutoTaskSchedule.Core.Reflects;
using Topshelf;
using Topshelf.ServiceConfigurators;
using AutoTaskSchedule.Core.Extensions;

namespace AutoTaskSchedule.TopShelf
{
    class Program
    {
        static void Main(string[] args)
        {
            //var classes = ReflectFactory.Reflect(@"D:\AutoTaskSchedule\src\Tests\AutoTaskSchedule.Test.TestTask\bin\Debug\AutoTaskSchedule.Test.TestTask.dll");
            //classes.ForEach(t => AutoTaskSchedule.Core.Business.JobFactory.Create(t));

            var taskListService = new TaskListService();
            //var configs = taskListService.FindAll();
            var task = new AutoTaskSchedule.Core.Models.Task();
            task.Name = "I am your father";
            task.Id = Guid.NewGuid();
            task.ClassName = "TestTask";
            task.TaskAssemblyFullName = @"D:\AutoTaskSchedule\src\Tests\AutoTaskSchedule.Test.TestTask\bin\Debug\AutoTaskSchedule.Test.TestTask.dll";
            //taskListService.New(task);
            //taskListService.New(task);
            //var configs = taskListService.FindAll();
            task.GetFactory().Create();
            Console.ReadKey();

            return;
            HostFactory.Run(cfgCallback =>
            {
                cfgCallback.Service<TopShelfService>(c =>
                {
                    c.ConstructUsing(s => new TopShelfService());
                    c.WhenStarted((service, hostControl) => service.Start(hostControl));
                    c.WhenStopped((service, hostControl) => service.Stop(hostControl));
                });


                cfgCallback.RunAsLocalSystem();
                cfgCallback.StartAutomatically();

                cfgCallback.SetDescription("description");
                cfgCallback.SetDisplayName("displayName");
                cfgCallback.SetServiceName("serviceName");
            });


        }
    }
}
